package Chapter5;
class Teacher implements Runnable{
	private int notes=80;
	public void run() {
		while(true) {
			divide();
			if(notes<=0) {
				break;
			}
		}
	}
	private synchronized void divide() {
		if(notes>0) {
			try {
				Thread.sleep(10);
			}catch(Exception e) {
				e.printStackTrace();
			}
			System.out.println(Thread.currentThread().getName()+" divided notes "+notes--);
		}
	}
}
public class Work3 {
	public static void main(String[] args) {
		Teacher t=new Teacher();
		new Thread(t,"Mr.L").start();
		new Thread(t,"Mr.X").start();
		new Thread(t,"Mr.Y").start();
	}

}
